import instacne from "../request";
import type { Ref } from "vue";

interface  ControllerParms{
    endTime?: string | Ref<string>;
    name?: string | Ref<string>;
    pageNum?: number | Ref<number>;
    pageSize?: number | Ref<number>;
    type?: string | Ref<string>;
  }

interface Controller{
    clickCount: number,
    endTime: string,
    id: number ,
    name: string,
    note: string,
    orderCount: number,
    pic: string,
    sort: number,
    startTime: string,
    status: number,
    type: number ,
    url: string
}

interface Controllerlist{
    list:Controller[]
    pageNum: number,
    pageSize: number,
    total: number,
    totalPage: number
}

// /advertise/list
const getControllerlist = (data?: ControllerParms): Promise<Controllerlist> => {
    return instacne.get("/home/advertise/list", {
      params: data,
    });
  };
  // /home/advertise/delete
  const getControllerdel = (data: number) => {
    return instacne.post(`/home/advertise/delete?ids=${data}`);
  };

  // /home/advertise/update/status/{id}
  const getControllerUpdatestatus = (data: Controller) => {
    return instacne.post(`/home/advertise/update/status/${data.id}?status=${data.status}`);
  };
  // /home/advertise/{id}
  const getControllerUpdate = (data: Controller) => {
    return instacne.get(`/home/advertise/${data.id}`, data);
  };
  // /home/advertise/create 添加
  const getControlleradd = (data: Controller): Promise<Controller> => {
    return instacne.post("/home/advertise/create", data);
  };
  // /home/advertise/update/{id}
  const getreturnReasonUpdate = (data: Controller) => {
    return instacne.post(`/home/advertise/update/${data.id}`, data);
  };

export {getControllerlist,getControllerdel,getControllerUpdatestatus,getControlleradd,getControllerUpdate,getreturnReasonUpdate}
export type { Controller};